<template>
	<view class="onebox">
		<view class="box1">

		</view>
		<view class="text1">
			切换账号登录
		</view>
		<view class="text2">
			轻触账号以登录
		</view>
		<view class="box3" v-for="(item,index) in list" :key="index" @click="cs(item.id)">
			<view class="cu-avatar lg round margin-left"
				style="background-image:url(../../static/cskx.jpg)"></view>
			<view class="text3">
				账号：{{item.name}}
			</view>
		</view>
		<!-- <view class="box4" @click="tzlogin">
			<image class="img" src="../../static/xz1.png" mode=""></image>
			<view class="text3">
				添加账号
			</view>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				key:'123456'
			}
		},
		onLoad() {
			this.key = uni.getStorageSync('key');
			this.GetSchoolList()
		},
		methods: {
			GetSchoolList() {
			
				var openid = uni.getStorageSync('openid');

				$api.request({
					url: "lt/getSchoolList",
					method: 'POST',
					data: {
						key: this.key,
					}
				}).then((res) => {
				console.log(res.data, '55555')
				this.list=res.data
				}).catch((res) => {
					uni.showToast({
						title: res.msg,
						icon: "none"
					})
				})
			},
			cs(school_id) {
				uni.setStorageSync('school_id', school_id)
						uni.navigateTo({
				
							url:'/pages/index/index'
						})
				// 以后会需要这部分
				// var dataList =uni.getStorageSync('dataList')
				// var that=this
				// var has=0;
				// dataList.forEach(function(it,i,dataList){
				// 	if(it.mobile==school_id){
						
				// 		uni.setStorageSync('storage_key', it.mobile)
				// 		uni.setStorageSync('usertoken', it.encPsd)
				// 		uni.navigateTo({

				// 			url: `/pages/login/index`
				// 		})
				// 		return
				// 	}
				// })
				
				// console.log(aaaa, '测试数据')
			},
			tzlogin() {
				// uni.setStorageSync('usertoken', '')
				uni.navigateTo({
					url: '/pages/login/login?type=2'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.onebox {
		min-height: 100vh;
		background-color: #fff;
	}

	.box1 {
		height: 30rpx;
	}

	.text1 {
		font-size: 50rpx;
		font-weight: 900;
		margin: 0rpx 30rpx;
	}

	.text2 {
		font-size: 26rpx;
		color: rgb(200, 200, 200);
		margin: 20rpx 30rpx;
	}

	.box3 {
		display: flex;
		align-items: center;
		margin: 50rpx 0;
		// margin-left: 30rpx;
	}

	.text3 {
		margin-left: 50rpx;
	}

	.img {
		width: 100rpx;
		height: 100rpx;
		margin-top: 0rpx;
	}

	.box4 {
		display: flex;
		align-items: center;
		margin-left: 30rpx;
	}
</style>